package com.function.controller;

import com.function.domin.pojo.Email;
import com.function.domin.pojo.Result;
import com.function.service.SendEmailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(tags = "发送邮件接口")
@RequestMapping("/email")
public class SendEmailController {

    @Autowired
    private SendEmailService sendEmailService;

    /**
     * 发送邮件
     * @param emailMessage
     * @return
     */
    @ApiOperation("发送邮件")
    @PostMapping ("/sendEmail")
    public Result sendEmail(@RequestBody Email emailMessage){

        log.info("发送邮件: {}", emailMessage);
        sendEmailService.sendEmail(emailMessage);

        return Result.success();
    }

}
